home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / TransSkel / Demos / Pascal Demos / Button / Dialog1.p < prev    next >
Encoding:
Text File  |  1994-02-23  |  1.6 KB  |  82 lines  |  [TEXT/PJMM]

  1. unit Dialog1;
  2.  
  3. interface
  4.  
  5.     uses
  6.         TransSkel, ButtonGlobals;
  7.  
  8.  
  9.     procedure DoDialog1;
  10.  
  11. implementation
  12.  
  13.     const
  14.  
  15.         iOK = 1;
  16.         iCancel = 2;
  17.         iEditText = 3;
  18.         iOutline = 4;
  19.  
  20.     var
  21.  
  22.         defaultButton: Integer;
  23.  
  24.  
  25. {--------------------------------------------------------------------}
  26. { Dialog 1 procedures }
  27. {--------------------------------------------------------------------}
  28.  
  29.     procedure DoDialog1;
  30.         var
  31.             filter: ModalFilterProcPtr;
  32.             dlog: DialogPtr;
  33.             savePort: GrafPtr;
  34.             item: Integer;
  35.             str: Str255;
  36.             hilite: Integer;
  37.             loop: Boolean;
  38.     begin
  39.         dlog := GetNewDialog(dlog1Res, nil, WindowPtr(-1));
  40.         if (dlog = DialogPtr(nil)) then
  41.             begin
  42.                 SysBeep(1);
  43.                 exit(DoDialog1);
  44.             end;
  45.  
  46.         SkelPositionWindow(dlog, skelPositionOnMainDevice, horizRatio, vertRatio);
  47.  
  48.         GetPort(savePort);
  49.         SetPort(dlog);
  50.  
  51.         SkelSetDlogButtonOutliner(dlog, iOutline);
  52.         SkelSetDlogStr(dlog, iEditText, 'Default button is active only when this field is non-empty');
  53.         SelItext(dlog, iEditText, 0, 32767);
  54.  
  55.         ShowWindow(dlog);
  56.  
  57.         loop := true;
  58.         while (loop) do
  59.             begin
  60.                 filter := SkelDlogFilter(nil, true);
  61.                 SkelDlogCancelItem(iCancel);
  62.                 ModalDialog(filter, item);
  63.                 SkelRmveDlogFilter;
  64.                 if ((item = iOK) or (item = iCancel)) then
  65.                     loop := false
  66.                 else
  67.                     begin
  68.                         SkelGetDlogStr(dlog, iEditText, str);
  69.                         if (length(str) > 0) then
  70.                             hilite := normalHilite
  71.                         else
  72.                             hilite := dimHilite;
  73.                         if (SkelSetDlogCtlHilite(dlog, iOK, hilite)) then
  74.                             SkelDrawButtonOutline(SkelGetDlogCtl(dlog, iOK));
  75.                     end;
  76.             end;
  77.  
  78.         DisposeDialog(dlog);
  79.         SetPort(savePort);
  80.     end;
  81.  
  82. end.